\hypertarget{classdev_1_1net_1_1_socket}{}\section{dev\+:\+:net\+:\+:Socket Class Reference}
\label{classdev_1_1net_1_1_socket}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}


套接字  




{\ttfamily \#include $<$Socket.\+hpp$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classdev_1_1net_1_1_socket_a7fa4fc9a046e73a5f8c1a20cb284e36e}{}{\bfseries Socket} (int domain, int type, int protocol=0)\label{classdev_1_1net_1_1_socket_a7fa4fc9a046e73a5f8c1a20cb284e36e}

\item 
\hypertarget{classdev_1_1net_1_1_socket_a40070074dfd48f04536bd0a027166293}{}{\bfseries Socket} (sock\+\_\+t sockfd)\label{classdev_1_1net_1_1_socket_a40070074dfd48f04536bd0a027166293}

\item 
sock\+\_\+t \hyperlink{classdev_1_1net_1_1_socket_aba630380ca8cde22e22a16ddcb4670ae}{get\+Socket} () const 
\begin{DoxyCompactList}\small\item\em 获取本地套接字 \end{DoxyCompactList}\item 
bool \hyperlink{classdev_1_1net_1_1_socket_ab4a310b0db236a8d55f2936373d36f5a}{is\+Valid} (void) const 
\begin{DoxyCompactList}\small\item\em 判断套接字是否有效 \end{DoxyCompactList}\item 
bool \hyperlink{classdev_1_1net_1_1_socket_ad6b109f9f6d599f65edf379866e3fe0b}{set\+Non\+Blocking} (bool on=true)
\begin{DoxyCompactList}\small\item\em 设置套接字阻塞状态 \end{DoxyCompactList}\item 
bool \hyperlink{classdev_1_1net_1_1_socket_a7acfefe85faea54804509eac0e082900}{set\+Reuse\+Addr} (bool on=false)
\begin{DoxyCompactList}\small\item\em 设置套接字阻塞是否重用地址 \end{DoxyCompactList}\item 
bool \hyperlink{classdev_1_1net_1_1_socket_aaddc13c0968b0652436155f8bd5c0daa}{set\+Linger} (bool on=false)
\begin{DoxyCompactList}\small\item\em 设置套接字linger状态 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_socket_adee8179a6f2d53861eeb13b398901845}{reset} (sock\+\_\+t sock)
\begin{DoxyCompactList}\small\item\em 重置内部原始本地套接字 \end{DoxyCompactList}\item 
void $\ast$ \hyperlink{classdev_1_1net_1_1_socket_af86b037ac9f6b916c8bc7b174a061297}{get\+User\+Data\+Ptr} ()
\begin{DoxyCompactList}\small\item\em 获取用户数据 \end{DoxyCompactList}\item 
int \hyperlink{classdev_1_1net_1_1_socket_a3888df2959501c6d40d021ddc3a47eaf}{get\+User\+Data\+Int} ()
\begin{DoxyCompactList}\small\item\em 获取用户数据 \end{DoxyCompactList}\item 
long \hyperlink{classdev_1_1net_1_1_socket_a8526950530c1f58529af1e8f3d225ede}{get\+User\+Data\+Long} ()
\begin{DoxyCompactList}\small\item\em 获取用户数据 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_socket_a09404a9a214270685b3f76addf02cd2c}{set\+User\+Data\+Ptr} (void $\ast$p\+V)
\begin{DoxyCompactList}\small\item\em 设置用户数据 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_socket_a1d666eda7b16aceca6feebc6151b2355}{set\+User\+Data\+Int} (int x)
\begin{DoxyCompactList}\small\item\em 设置用户数据 \end{DoxyCompactList}\item 
void \hyperlink{classdev_1_1net_1_1_socket_a5bcb192e9d5da628370c89e357a0103f}{set\+User\+Data\+Long} (long x)
\begin{DoxyCompactList}\small\item\em 设置用户数据 \end{DoxyCompactList}\item 
int \hyperlink{classdev_1_1net_1_1_socket_a25675e062ae83762dd1e25ef745f6ba1}{receive} (char $\ast$buff, size\+\_\+t length, int flags=0)
\begin{DoxyCompactList}\small\item\em 接收数据 \end{DoxyCompactList}\item 
int \hyperlink{classdev_1_1net_1_1_socket_af2218f65624a640161009ddd0bfa509e}{send} (const char $\ast$buff, size\+\_\+t length, int flags=0)
\begin{DoxyCompactList}\small\item\em 发送数据 \end{DoxyCompactList}\item 
\hypertarget{classdev_1_1net_1_1_socket_abf71d50699036a8a69cb362a9ac7ad02}{}void \hyperlink{classdev_1_1net_1_1_socket_abf71d50699036a8a69cb362a9ac7ad02}{close} (void)\label{classdev_1_1net_1_1_socket_abf71d50699036a8a69cb362a9ac7ad02}

\begin{DoxyCompactList}\small\item\em 关闭套接字 \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classdev_1_1net_1_1_socket_a43fe1eaa6c6b4d4ecbb2ba361d312b66}{}class {\bfseries Tcp\+Connection}\label{classdev_1_1net_1_1_socket_a43fe1eaa6c6b4d4ecbb2ba361d312b66}

\item 
\hypertarget{classdev_1_1net_1_1_socket_a810e9e3048210a2e29dbd5cdd6f5812d}{}class {\bfseries Tcp\+Acceptor}\label{classdev_1_1net_1_1_socket_a810e9e3048210a2e29dbd5cdd6f5812d}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
套接字 

\subsection{Member Function Documentation}
\hypertarget{classdev_1_1net_1_1_socket_aba630380ca8cde22e22a16ddcb4670ae}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!get\+Socket@{get\+Socket}}
\index{get\+Socket@{get\+Socket}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{get\+Socket() const }]{\setlength{\rightskip}{0pt plus 5cm}sock\+\_\+t dev\+::net\+::\+Socket\+::get\+Socket (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_aba630380ca8cde22e22a16ddcb4670ae}


获取本地套接字 

\begin{DoxyReturn}{Returns}
sock\+\_\+t 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_a3888df2959501c6d40d021ddc3a47eaf}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!get\+User\+Data\+Int@{get\+User\+Data\+Int}}
\index{get\+User\+Data\+Int@{get\+User\+Data\+Int}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{get\+User\+Data\+Int()}]{\setlength{\rightskip}{0pt plus 5cm}int dev\+::net\+::\+Socket\+::get\+User\+Data\+Int (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_a3888df2959501c6d40d021ddc3a47eaf}


获取用户数据 

\begin{DoxyReturn}{Returns}
int 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_a8526950530c1f58529af1e8f3d225ede}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!get\+User\+Data\+Long@{get\+User\+Data\+Long}}
\index{get\+User\+Data\+Long@{get\+User\+Data\+Long}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{get\+User\+Data\+Long()}]{\setlength{\rightskip}{0pt plus 5cm}long dev\+::net\+::\+Socket\+::get\+User\+Data\+Long (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_a8526950530c1f58529af1e8f3d225ede}


获取用户数据 

\begin{DoxyReturn}{Returns}
long 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_af86b037ac9f6b916c8bc7b174a061297}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!get\+User\+Data\+Ptr@{get\+User\+Data\+Ptr}}
\index{get\+User\+Data\+Ptr@{get\+User\+Data\+Ptr}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{get\+User\+Data\+Ptr()}]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ dev\+::net\+::\+Socket\+::get\+User\+Data\+Ptr (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_af86b037ac9f6b916c8bc7b174a061297}


获取用户数据 

\begin{DoxyReturn}{Returns}
void$\ast$ 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_ab4a310b0db236a8d55f2936373d36f5a}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!is\+Valid@{is\+Valid}}
\index{is\+Valid@{is\+Valid}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{is\+Valid(void) const }]{\setlength{\rightskip}{0pt plus 5cm}bool dev\+::net\+::\+Socket\+::is\+Valid (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_ab4a310b0db236a8d55f2936373d36f5a}


判断套接字是否有效 

\begin{DoxyReturn}{Returns}
bool 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_a25675e062ae83762dd1e25ef745f6ba1}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!receive@{receive}}
\index{receive@{receive}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{receive(char $\ast$buff, size\+\_\+t length, int flags=0)}]{\setlength{\rightskip}{0pt plus 5cm}int Socket\+::receive (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{buff, }
\item[{size\+\_\+t}]{length, }
\item[{int}]{flags = {\ttfamily 0}}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_socket_a25675e062ae83762dd1e25ef745f6ba1}


接收数据 


\begin{DoxyParams}{Parameters}
{\em buff} & 数据缓存 \\
\hline
{\em length} & 数据缓存长度 \\
\hline
{\em flags} & 标志 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
成功返回接收的数据长度，如果套接字非阻塞且数据 已接收完返回\+S\+O\+C\+K\+E\+T\+\_\+\+E\+R\+R\+O\+R\+\_\+\+W\+O\+U\+L\+D\+B\+L\+O\+C\+K，错误返回\+S\+O\+C\+K\+E\+T\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_adee8179a6f2d53861eeb13b398901845}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!reset@{reset}}
\index{reset@{reset}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{reset(sock\+\_\+t sock)}]{\setlength{\rightskip}{0pt plus 5cm}void Socket\+::reset (
\begin{DoxyParamCaption}
\item[{sock\+\_\+t}]{sock}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_socket_adee8179a6f2d53861eeb13b398901845}


重置内部原始本地套接字 


\begin{DoxyParams}{Parameters}
{\em sock} & \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_socket_af2218f65624a640161009ddd0bfa509e}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!send@{send}}
\index{send@{send}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{send(const char $\ast$buff, size\+\_\+t length, int flags=0)}]{\setlength{\rightskip}{0pt plus 5cm}int Socket\+::send (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{buff, }
\item[{size\+\_\+t}]{length, }
\item[{int}]{flags = {\ttfamily 0}}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_socket_af2218f65624a640161009ddd0bfa509e}


发送数据 


\begin{DoxyParams}{Parameters}
{\em buff} & 数据缓存 \\
\hline
{\em length} & 数据缓存长度 \\
\hline
{\em flags} & 标志 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
成功发送接收的数据长度，如果套接字非阻塞且数据 发送缓存已满返回\+S\+O\+C\+K\+E\+T\+\_\+\+E\+R\+R\+O\+R\+\_\+\+W\+O\+U\+L\+D\+B\+L\+O\+C\+K，错误返回\+S\+O\+C\+K\+E\+T\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_aaddc13c0968b0652436155f8bd5c0daa}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!set\+Linger@{set\+Linger}}
\index{set\+Linger@{set\+Linger}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{set\+Linger(bool on=false)}]{\setlength{\rightskip}{0pt plus 5cm}bool Socket\+::set\+Linger (
\begin{DoxyParamCaption}
\item[{bool}]{on = {\ttfamily false}}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_socket_aaddc13c0968b0652436155f8bd5c0daa}


设置套接字linger状态 


\begin{DoxyParams}{Parameters}
{\em on} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
bool 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_ad6b109f9f6d599f65edf379866e3fe0b}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!set\+Non\+Blocking@{set\+Non\+Blocking}}
\index{set\+Non\+Blocking@{set\+Non\+Blocking}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{set\+Non\+Blocking(bool on=true)}]{\setlength{\rightskip}{0pt plus 5cm}bool Socket\+::set\+Non\+Blocking (
\begin{DoxyParamCaption}
\item[{bool}]{on = {\ttfamily true}}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_socket_ad6b109f9f6d599f65edf379866e3fe0b}


设置套接字阻塞状态 


\begin{DoxyParams}{Parameters}
{\em on} & 是否阻塞 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
bool 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_a7acfefe85faea54804509eac0e082900}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!set\+Reuse\+Addr@{set\+Reuse\+Addr}}
\index{set\+Reuse\+Addr@{set\+Reuse\+Addr}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{set\+Reuse\+Addr(bool on=false)}]{\setlength{\rightskip}{0pt plus 5cm}bool Socket\+::set\+Reuse\+Addr (
\begin{DoxyParamCaption}
\item[{bool}]{on = {\ttfamily false}}
\end{DoxyParamCaption}
)}\label{classdev_1_1net_1_1_socket_a7acfefe85faea54804509eac0e082900}


设置套接字阻塞是否重用地址 


\begin{DoxyParams}{Parameters}
{\em on} & 是否重用地址 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
bool 
\end{DoxyReturn}
\hypertarget{classdev_1_1net_1_1_socket_a1d666eda7b16aceca6feebc6151b2355}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!set\+User\+Data\+Int@{set\+User\+Data\+Int}}
\index{set\+User\+Data\+Int@{set\+User\+Data\+Int}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{set\+User\+Data\+Int(int x)}]{\setlength{\rightskip}{0pt plus 5cm}void dev\+::net\+::\+Socket\+::set\+User\+Data\+Int (
\begin{DoxyParamCaption}
\item[{int}]{x}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_a1d666eda7b16aceca6feebc6151b2355}


设置用户数据 


\begin{DoxyParams}{Parameters}
{\em int} & \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_socket_a5bcb192e9d5da628370c89e357a0103f}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!set\+User\+Data\+Long@{set\+User\+Data\+Long}}
\index{set\+User\+Data\+Long@{set\+User\+Data\+Long}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{set\+User\+Data\+Long(long x)}]{\setlength{\rightskip}{0pt plus 5cm}void dev\+::net\+::\+Socket\+::set\+User\+Data\+Long (
\begin{DoxyParamCaption}
\item[{long}]{x}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_a5bcb192e9d5da628370c89e357a0103f}


设置用户数据 


\begin{DoxyParams}{Parameters}
{\em long} & \\
\hline
\end{DoxyParams}
\hypertarget{classdev_1_1net_1_1_socket_a09404a9a214270685b3f76addf02cd2c}{}\index{dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}!set\+User\+Data\+Ptr@{set\+User\+Data\+Ptr}}
\index{set\+User\+Data\+Ptr@{set\+User\+Data\+Ptr}!dev\+::net\+::\+Socket@{dev\+::net\+::\+Socket}}
\subsubsection[{set\+User\+Data\+Ptr(void $\ast$p\+V)}]{\setlength{\rightskip}{0pt plus 5cm}void dev\+::net\+::\+Socket\+::set\+User\+Data\+Ptr (
\begin{DoxyParamCaption}
\item[{void $\ast$}]{p\+V}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}\label{classdev_1_1net_1_1_socket_a09404a9a214270685b3f76addf02cd2c}


设置用户数据 


\begin{DoxyParams}{Parameters}
{\em void$\ast$} & \\
\hline
\end{DoxyParams}


The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
dev/dev/net/Socket.\+hpp\item 
dev/src/net/Socket.\+cpp\end{DoxyCompactItemize}
